package com.sso.exception;

import com.zbf.pojo.ResponseResult;
import org.apache.catalina.util.RequestUtil;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * 作者: LCG
 * 日期: 2019/8/6 15:14
 * 描述: 统一的异常处理类
 */


@ControllerAdvice
public class MyException {

    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public ResponseResult exceptionHandler(HttpServletRequest request, Exception e) {

        e.printStackTrace();

        ResponseResult responseResult = ResponseResult.getResponseResult();

        responseResult.setCode(500);
        responseResult.setError(e.getMessage());

        return responseResult;
    }

}
